package com.test.deencredit.view_deencredit.process_widget_deencredit;

import static android.view.View.GONE;
import static android.view.View.VISIBLE;

import android.graphics.Color;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.test.deencredit.R;
import com.test.deencredit.base_deencredit.BaseProcessWidgetManager_deencredit;
import com.test.deencredit.bean_deencredit.process_deencredit.ProcessInfo_Data_deencredit;
import com.test.deencredit.util_deencredit.http_deencredit.HttpUtil_deencredit;


public class GenderSelectViewManager_deencredit extends BaseProcessWidgetManager_deencredit {

    private TextView titleTv_deencredit;
    private TextView maleTv_deencredit, femaleTv_deencredit;

    private boolean isMale_deencredit = true;

    public GenderSelectViewManager_deencredit(View view, ProcessInfo_Data_deencredit data, String pageTag){
        super(view,data,pageTag);
    }

    @Override
    protected void init_deencredit(){

        titleTv_deencredit = mView_deencredit.findViewById(R.id.vpgs_tv_title);
        maleTv_deencredit = mView_deencredit.findViewById(R.id.vpgs_tv_male);
        femaleTv_deencredit = mView_deencredit.findViewById(R.id.vpgs_tv_female);

        maleTv_deencredit.setOnClickListener(v -> setGender_deencredit(true));
        femaleTv_deencredit.setOnClickListener(v -> setGender_deencredit(false));

        setTitle_deencredit(mData_deencredit.getTitle_deencredit());

    }

    @Override
    public boolean checkInput_deencredit() {
        return true;
    }

    @Override
    public String getInput_deencredit() {
        return isMale_deencredit ? "MALE":"FEMALE";
    }

    public void setGender_deencredit(boolean isMale){
        this.isMale_deencredit = isMale;
        if (isMale){
            maleTv_deencredit.setBackgroundResource(R.drawable.bg_purple_t_rc24dp_border_purple_1dp_deencredit);
            maleTv_deencredit.setTextColor(mView_deencredit.getContext().getColor(R.color.purple_main_deencredit));
            femaleTv_deencredit.setBackgroundResource(R.drawable.bg_gray_rc24dp_deencredit);
            femaleTv_deencredit.setTextColor(Color.parseColor("#FF6C6C6C"));
        }else {
            maleTv_deencredit.setBackgroundResource(R.drawable.bg_gray_rc24dp_deencredit);
            maleTv_deencredit.setTextColor(Color.parseColor("#FF6C6C6C"));
            femaleTv_deencredit.setBackgroundResource(R.drawable.bg_purple_t_rc24dp_border_purple_1dp_deencredit);
            femaleTv_deencredit.setTextColor(Color.parseColor("#FF6C6C6C"));
        }

        HttpUtil_deencredit.getInstance_deencredit().saveBuriedPoint_deencredit(page_deencredit, mData_deencredit.getParamName_deencredit().toUpperCase()+"_CLICK", getInput_deencredit());
    }

    public void setTitle_deencredit(String title){
        if (TextUtils.isEmpty(title)) titleTv_deencredit.setVisibility(GONE);
        else {
            titleTv_deencredit.setVisibility(VISIBLE);
            titleTv_deencredit.setText(title);
        }
    }

}
